<?php

namespace App\Http\Middleware;

use Closure;
use Auth;
use Request;

class AdminAuthenticate
{
    public static $uneed_check = array('/admin/login','/admin/logout','/admin/verify');
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
//        dd($request->user());
        if(!in_array(Request::getPathInfo(),AdminAuthenticate::$uneed_check)){
            if(!Auth::guard('admin')->check()){
                return redirect('/admin/login');
            }
        }
        return $next($request);
    }
}
